

function ItemManager(divName, peer){
     //var divName;
     var template = "itemTemplate";
     var itemsImgs = new Array();
     var myitems = new Object();
     this.update = function (items, peer){
          var data = new Object ();
          myitems = new Object();
          data["items"] = items;
          data["peer"] = peer;
          for (var i=0; i<items.length; i++){
            myitems["_item_"+peer+"_"+items[i].id] = items[i];
			items[i].x = i*100;
	  	  }
	  	  $(divName).innerHTML= TrimPath.processDOMTemplate(template, data);
	  	  for (var i=0; i<items.length; i++){
	  	    //alert("_item_"+peer+"_"+items[i].id);
	  	    if (!dd.elements["_item_"+peer+"_"+items[i].id] ||dd.elements["_item_"+peer+"_"+items[i].id] == null){
	  	  		ADD_DHTML("_item_"+peer+"_"+items[i].id);
	  	  	}
	  	  	items[i].pixx = dd.elements["_item_"+peer+"_"+items[i].id].x;
	  	    items[i].pixy = dd.elements["_item_"+peer+"_"+items[i].id].y;
	  	  }
	  	  
	}
	
	this.getItem = function (itemid){
	  return myitems[itemid];
	}
	
	
}